﻿Imports UCBase
Imports System.Drawing
Imports System.Windows.Forms
Imports UCBase.DiagramPanel

Public Class TabMonitor
    Implements I_LoadSave
    Implements I_EditMode

    Private BackPic As New BackgroundCreator
    Private Mover As New Mover
    Private M_Edit As Boolean = True
    Private WithEvents ImageInput As I_ImageExchange
    Private PT As Integer
    Private AC As Integer = 0
    Private AV As Integer = 0
    Private FPS As Integer
    Private M_Resources As ResourceManager
    Private Pic As New OSDPictureBox
    Private M_Font As New Font(System.Drawing.FontFamily.GenericSansSerif, 1, FontStyle.Bold, GraphicsUnit.Millimeter)
    Private OSD As Boolean = True
    Private M_Name As String = "TabMonitor"
    Public Overloads Property Name() As String
        Get
            Return M_Name
        End Get
        Set(ByVal value As String)
            M_Name = value
        End Set
    End Property
    Public WriteOnly Property Resources() As ResourceManager
        Set(ByVal value As ResourceManager)
            M_Resources = value
        End Set
    End Property
    Public Sub CreateTab()
        Dim X As New TabPage(M_Name)
        X.BorderStyle = BorderStyle.Fixed3D
        X.ImageIndex = 1
        M_Resources.MainTab.TabPages.Insert(M_Resources.MainTab.TabPages.Count - 1, X)
        Pic.Dock = DockStyle.Fill
        Pic.Visible = True
        Pic.BackColor = Color.Black
        Pic.SizeMode = PictureBoxSizeMode.Zoom
        Pic.OSDBack = Color.DarkGray
        Pic.OSDFore = Color.White
        Pic.ButtonFore = Color.Silver
        Pic.ButtonHiliteColor = Color.Red
        Pic.OSDOpacity = 50
        X.Controls.Add(Pic)
    End Sub
    Public Function GetSettings() As String Implements I_LoadSave.GetSettings
        Return ""
    End Function

    Public Sub SetSettings(ByVal Settings As String) Implements I_LoadSave.SetSettings

    End Sub

    Private Sub Socket2_Connect() Handles Socket2.Connect
        If Socket2.SocketType = Socket.Socket_Type.Image Then
            Dim S As Socket = Socket2.Remote
            ImageInput = S.Parent
        End If
    End Sub

    Private Sub ImageInput_ImageReady(ByVal Image As System.Drawing.Bitmap) Handles ImageInput.ImageOut1
        If Image IsNot Nothing Then
            Dim BMP As New Bitmap(Image)
            Dim G As Graphics = Graphics.FromImage(BMP)
            Pic.DisplayImage = BMP
        End If
    End Sub

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.BackgroundImage = BackPic.CreatePic(Me.Width, Me.Height, Color.Silver)
        Mover.Connect(Me)
        Label1.Text = M_Name
        Label1.BackColor = BackPic.FaceColor

    End Sub
    Private Sub TabMonitor_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Me.Width = 155
        Me.Height = 75

    End Sub

    Public Sub SetEditMode1(ByVal Mode As UCBase.Diagram.EditMode) Implements UCBase.I_EditMode.SetEditMode
        If Mode = Diagram.EditMode.Locked Then
            Label1.Text = M_Name
            Label1.Left = 10
            Label1.Top = 10
            TextBox1.Top = -100
            TextBox1.Left = -100
            Mover.EditMode = False
        Else
            TextBox1.Text = M_Name
            Label1.Left = -100
            Label1.Top = -100
            TextBox1.Top = 10
            TextBox1.Left = 10
            Mover.EditMode = True
        End If
    End Sub

    Private Sub TabMonitor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
